<!----------------------------------------------------
ページ名：ClubNL.jsp
所　　属：H3A1 04
名　　前：大瀬碩
説　　明：選択したクラブ情報を表示するページ
------------------------------------------------------>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page import="java.sql.*"%>
    <%@page import="java.io.*"%>
<%@page import="java.util.Properties"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="css/bootstrap.min.css" rel="stylesheet">
<title>クラブ活動情報</title>
</head>
<body>
</head>
<body>

<!-- ナビゲーションバー -->
<div class="navbar navbar-default">
  <div class="navbar-header">
    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </button>
    <a class="navbar-brand" href="index.jsp"><img alt="" src="images/logo2.png"></a>
  </div>
  <div class="navbar-collapse collapse">
    <ul class="nav navbar-nav">
      <li><a href="TimetableClassSelection.jsp">時間割情報</a></li>
      <li class="active"><a href="ClubList.jsp">部活動情報</a></li>
    </ul>
    <ul class="nav navbar-nav navbar-right">
      <li><a href="Login.jsp">ログイン</a></li>
    </ul>
  </div>
</div>
	<h1 align="center">
	<%
	//クラブ名表示
	ServletContext context = this.getServletContext();
	String path = context.getRealPath("/WEB-INF/connect.properties");
	
	InputStream in = new FileInputStream(path);
	Properties properties = new Properties();
	properties.load(in);
	in.close();
	
	HttpSession sess = request.getSession(true);
	Object sel_club = sess.getAttribute("sel_club");
	Class.forName("com.mysql.jdbc.Driver");
	Connection conn = null;
	String url = properties.getProperty("key1");
	String user = properties.getProperty("key2");
	String password = properties.getProperty("key3");
	conn = DriverManager.getConnection(url, user, password);
	Statement stmt = conn.createStatement();
	String sql = "SELECT * FROM club WHERE club_id = "+sel_club;
	ResultSet rs = stmt.executeQuery(sql);
	while(rs.next()){
		out.print(rs.getString("club_name"));
	}
	rs.close();
	stmt.close();
	conn.close();
	%>
	</h1>
	<%
	//クラブの画像表示
	if("1".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/futsal.png\" style=\"height: 270px;\"></h1>");
	}
	if("2".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/baseball.png\" style=\"height: 270px;\"></h1>");
	}
	if("3".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/tennis.png\" style=\"height: 270px;\"></h1>");
	}
	if("4".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/soft_tennis.png\" style=\"height: 270px;\"></h1>");
	}
	if("5".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/badminton.png\" style=\"height: 270px;\"></h1>");
	}
	if("6".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/table_tennis.png\" style=\"height: 270px;\"></h1>");
	}
	if("7".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/programming.png\" style=\"height: 270px;\"></h1>");
	}
	if("8".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/qualification.png\" style=\"height: 270px;\"></h1>");
	}
	if("9".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/light_music.png\" style=\"height: 270px;\"></h1>");
	}
	if("10".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/cinema.png\" style=\"height: 270px;\"></h1>");
	}
	if("11".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/reading.png\" style=\"height: 270px;\"></h1>");
	}
	if("12".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/gardening.png\" style=\"height: 270px;\"></h1>");
	}
	%>
	<div class="container">
		<div class="col-md-6">
			<table>
				<tr>
					<td>
						<h2 align="center">大会実績</h2>
						<div class="well" style="font-size: large">
							${ requestScope.jisseki }
						</div>
					</td>
				</tr>
				
				<tr><td>　</td></tr>
				
				<tr>
					<td>
						<h2 align="center">ひとこと</h2>
						<div class="well" style="font-size: large">
							${ requestScope.hitokoto }
						</div>
					</td>
				</tr>
			</table>
		</div>
		
		<div class="col-md-5 col-md-offset-1">
			<h2 align="center">部員一覧</h2>
			<table class="table table-bordered table-striped" style="font-size: large">
				<tr class="success">
					<th>
						部員名
					</th>
					<th>
						学年
					</th>
					<th>
						クラス
					</th>
				</tr>
				
				<%
				//部員一覧を表示
				Class.forName("com.mysql.jdbc.Driver");
				conn = null;
				conn = DriverManager.getConnection(url, user, password);
				stmt = conn.createStatement();
				sql = "SELECT * FROM student,class WHERE student.class_id = class.class_id"+
				" AND club_id = "+sel_club+" ORDER BY  `class`.`grade_id` DESC";
				rs = stmt.executeQuery(sql);
				while(rs.next()){
					out.println("<tr>");
					out.println("<td>");
					out.println(rs.getString("student_name"));
					out.println("</td>");
					out.println("<td>");
					out.println(rs.getString("grade_id")+"年");
					out.println("</td>");
					out.println("<td>");
					out.println(rs.getString("class_name"));
					out.println("</td>");
				}
				rs.close();
				stmt.close();
				conn.close();
				%>
			</table>
		</div>
	</div>
	
	<div align="center">
		<a href="ClubList.jsp" class="btn btn-lg btn-danger"><i class="glyphicon glyphicon-arrow-left"><br>部活動選択へ戻る</i></a>
		<a href="index.jsp" class="btn btn-lg btn-danger"><i class="glyphicon glyphicon-home"><br>トップへ</i></a>
	</div>
</body>
</html>